import devconsts
import logging
import os
import webapp2

from bin.build_dev import DevBuilder
from google.appengine.api import users
from google.appengine.ext.webapp import template


class DevJsPage(webapp2.RequestHandler):
  def get(self):
    user = users.get_current_user()
    if not user:
      self.redirect(users.create_login_url(self.request.uri))
      return

    dev_builder = DevBuilder()
    dev_js = dev_builder.concatFiles(devconsts.DEV_JS_FILES)

    self.response.headers['Content-Type'] = 'text/javascript; charset=UTF-8'
    self.response.out.write(dev_js)


app = webapp2.WSGIApplication([
  ('/devjs', DevJsPage)
], debug=True)
